﻿//-----------------------------------------------------------------------
// <copyright file="PageingHelpers.cs" company="上海Zoomla!逐浪CMS团队 ">
// 版权所有：江西逐浪软件科技有限公司  16年专注研发==>商城|ERP|字库|高端门户与人工智能 
// Website:www.z01.com 
// Contact:☎ 13177777714  😎 wechat: zoomla 
// Effect: 添加Html输助器方法,实现分页
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.Mvc;
using SportsStore.WebUI.Models;
using System.Web.UI;
using System.Runtime.Remoting.Messaging;

namespace SportsStore.WebUI.HtmlHelpers
{
    public static class PagingHelpers
    {
        public static MvcHtmlString PageLinks(this HtmlHelper html,PagingInfo pagingInfo, Func<int,string> pageUrl)
        {
            StringBuilder result = new StringBuilder();
            for (int i = 1; i <= pagingInfo.TotalPages; i++)
            {
                TagBuilder tag = new TagBuilder("a");
                tag.MergeAttribute("href", pageUrl(i));
                tag.InnerHtml = i.ToString();
                if (i == pagingInfo.CurrentPage)
                {
                    tag.AddCssClass("selected");
                    tag.AddCssClass("btn-primary");
                }
                tag.AddCssClass("btn btn-default");
                result.Append(tag.ToString());
            }
        return MvcHtmlString.Create(result.ToString());

        }
    }
}